/*************************************************************************
 *                                                                       *
 * This file is part of the FreeMAPs distribution.  For full copyright   *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:        sqbang                                                 *
 * Email:         sqbang@ustc.edu                                        *
 * Date:          2014.10.12                                             *
 * Description:   diffusion equation ensemble                            *
 *                                                                       *
 *************************************************************************/

#ifndef FreeMAPs_include_COMMON_equa_HeatConductionEquationEnsemble_h
#define FreeMAPs_include_COMMON_equa_HeatConductionEquationEnsemble_h

#include "FreeMAPsConfig.h"

//COMMON headers
#include "COMMON/equa/PDEEquationEnsembleStrategy.h"

namespace FreeMAPs
{

//forward declaration
class Function;
#ifdef FREEMAPS_HAVE_SAMRAI
class AttributeOfCell;
#endif

/**
 * @brief HeatConductionEquationEnsemble describe the diffusion equations:
 *  rho*c*df/dt - K*d^2f/dr^2 - Source = 0.
 * so the following parameters should be set:
 *  rho, C, K and Q.
 * if the equation is steady, or df/dt = 0, the equation will be Poisson equation.
 */
class HeatConductionEquationEnsemble : public PDEEquationEnsembleStrategy
{
public:

    HeatConductionEquationEnsemble (
        const std::string& parent_name,
        const std::string& object_name/*,
        const int sys_id*/);

    virtual
    ~HeatConductionEquationEnsemble();

public:

    inline virtual EquationEnsembleType
    get_equation_ensemble_type() const;

    inline int
    get_max_temporal_order() const;

    inline int
    get_num_of_stored_solutions() const;

    inline int
    get_ghost_width () const;

    inline bool
    is_steady() const;

    inline const Variable*
    get_var_temperature() const;

    inline bool
    use_effect_capacity() const;

    inline const std::string &
    get_coef_name_of_phase_change_latent_heat()const;

    inline const std::string &
    get_coef_name_of_phase_change_temperature_inf()const;

    inline const std::string &
    get_coef_name_of_phase_change_temperature_sup()const;

    inline const bool
    has_decomposite_effection() const;

    inline void
    set_has_decomposite_effection(
            const bool& has_decomposite_effection);


public:
    virtual void
    get_info_for_derived_object_from_input (
        const InputDatabase* db);

    virtual std::string
    get_info_from_derived_object() const;



protected:

    typedef PDEEquationEnsembleStrategy Parent;

    /*
     * poisson equation will be taken as a steady equation of diffusion equation
     */
    bool d_is_steady;

    bool d_has_decomposite_effection;

//    const Variable* d_var_temperature;
    //for composite material simulation
//    Variable* d_decomposite_factor;
    std::string d_coef_decomposite_rate_name;

    /*
     * for phase change problem, we can use effect capacity method to deal with
     * if not, use another method.
     */
    bool d_use_effect_capacity;

    /*
     * for isothermal phase change problem and no use effect capacity method, we need store latent heat;
     */
//    std::map<const libMesh::Node*, double> d_node_latent_heat;

    /*
     * we set the coefficiet's name.
     * NOTE that only the name is set, the detail of coefficiet
     * will be set in attribute file.
     */
    std::string d_coef_name_of_density;
    std::string d_coef_name_of_capacity;
    std::string d_coef_name_of_conductance_x;
    std::string d_coef_name_of_conductance_y;
    std::string d_coef_name_of_conductance_z;

    std::string d_coef_name_of_phase_change_temperature_inf;
    std::string d_coef_name_of_phase_change_temperature_sup;
    std::string d_coef_name_of_phase_change_latent_heat;

//    Function* d_coef_source;         //SOURCE, source is not an attribute of material, so set it directly.
    double d_init_total_mass;

private:

    DISALLOW_COPY_AND_ASSIGN (HeatConductionEquationEnsemble);
};

}

#include "COMMON/equa/HeatConductionEquationEnsemble.inl"

#endif
